import {request} from "../network/request";
import store from "../store";

export const dictMap = function (){
	let options = {};
	let dictValues = {};
	
	request({
		url: '/sys/font-dict-cache',
		method: 'get'
	}).then(vo=>{
		console.log('加载dictMap')
		let sysParams = vo.data;
		if(sysParams){
			options = sysParams.dictTypeMap;
			dictValues = sysParams.dictValueMap;
			store.commit('setDictOptions',options);
			// console.log('options',options)
		}
	})

	function get(key) {
		return options[key];
	}

	function getLabel(key){ //key为 'code + : + value'
		return dictValues[key];
	}

	return {
		options,
		get,
		getLabel,
		dictValues
	}
}();
